#include <algorithm>
#include <iostream>
#include <queue>
using namespace std;

const int kMaxM = 1e4 + 10;
const int kMaxG = 1e3 + 10;
const int kInf = 1e9;

int dis[kMaxM][kMaxG];
int a[kMaxM];

int BFS(int m, int g, int r) {
  queue<pair<int, int>> que[2];
  int dir[2] = {1, -1};

  // cout << m << " " << g << " " << r << endl;
  for (int i = 0; i < m; i++) {
    fill(dis[i], dis[i] + g, kInf);
  }
  dis[0][0] = 0;
  que[dis[0][0] & 1].emplace(0, 0);
  for (int d = 0; que[0].size() + que[1].size(); d++) {
    queue<pair<int, int>> &now = que[d & 1];

    for (; !now.empty(); now.pop()) {
      int p = now.front().first, t = now.front().second;

      if (dis[p][t] != d) {
        continue;
      }

      // cout << d << ": " << p << " " << t << endl;
      for (int delta : dir) {
        int np = delta + p;
        if (np >= 0 && np < m) {
          int nt = t + abs(a[np] - a[p]);
          int nd = dis[p][t];

          if (nt > g) {
            continue;
          }
          if (nt == g) {
            nd++;
            nt = 0;
          }
          if (dis[np][nt] > nd) {
            dis[np][nt] = nd;
            que[nd & 1].emplace(np, nt);
          }
        }
      }
    }
  }

  int ret = dis[m - 1][0] != kInf ? dis[m - 1][0] * (g + r) - r : kInf;

  for (int i = 1; i < g; i++) {
    if (dis[m - 1][i] != kInf) {
      ret = min(ret, dis[m - 1][i] * (g + r) + i);
    }
  }
  return ret == kInf ? -1 : ret;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, m, g, r;

  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
  }
  cin >> g >> r;
  sort(a, a + m);
  cout << BFS(m, g, r) << "\n";
  return 0;
}